package com.findyou.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.findyou.pojo.Headline;
import com.findyou.service.HeadlineService;
import com.findyou.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Title: HeadLineController
 * @Author 贾金博
 * @Package com.findyou.controller
 * @Date 2024/3/7 22:01
 * @description:
 */

@RestController
@RequestMapping("headline")
@CrossOrigin // 可以跨域
public class HeadLineController {

    @Autowired
    private HeadlineService headlineService;

    @PostMapping("publish")
    public Result publish(@RequestBody  Headline headline, @RequestHeader String token) {

        Result result = headlineService.publish(headline, token);
        return result;
    }

    @PostMapping("findHeadlineByHid")
    public Result findHeadlineByHid(int hid) {
        Result result = headlineService.findHeadlineByHid(hid);
        return result;
    }

    @PostMapping("update")
    public Result update(@RequestBody Headline headline) {
        headlineService.updateByMySelf(headline);
        return Result.ok(null);
    }

    @PostMapping("removeByHid")
    public Result removeByHid(int hid) {
        headlineService.removeByHid(hid);
        return Result.ok(null);
    }

}
